﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Core.Interfaces;
using Core.Interfaces.IDAO;
using Core.Unity;
using Microsoft.Practices.Unity;

namespace Core.Reports
{
    public partial class ForthReport : Form
    {
        private IActionDAO _actionDao;
        private ICustomerDAO _customerDao;
        private IOwnedBuildingDAO _ownedBuildingDao;
        public ForthReport()
        {
            InitializeComponent();
            _actionDao = ResolverContainer.Resolver.Resolve<IActionDAO>();
            _customerDao = ResolverContainer.Resolver.Resolve<ICustomerDAO>();
            _ownedBuildingDao = ResolverContainer.Resolver.Resolve<IOwnedBuildingDAO>();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            var customers = new List<ICustomer>();
            var actions = _actionDao.GetBySelect(string.Format("date='{0}'", dateTimePicker1.Value), false);
            foreach (var action in actions)
            {
                var ob =_ownedBuildingDao.GetAll(true).Where(x => x.Action.ActionId == action.ActionId);
                foreach (var ownedBuilding in ob)
                {
                    customers.Add(ownedBuilding.Customer);
                }
            }

            iCustomerBindingSource.DataSource =customers;
        }

        private void iCustomerBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }
    }
}
